package net.huashitong.Indicators.service;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.huashitong.Indicators.dao.CompletionClassificationDao;
import net.huashitong.Indicators.entity.CompletionClassification;
import net.huashitong.Indicators.filter.CompletionClassificationFilter;
import net.huashitong.Indicators.filter.IndicatorBreakdownFilter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.utils.ObjectUtils;
@Service
public class CompletionClassificationService extends StringPKService<CompletionClassification> {

	@Autowired
	private CompletionClassificationDao dao;
	private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private DecimalFormat dfs=new DecimalFormat("##.##");
	@Override
	protected BaseDao<CompletionClassification, String> getDao() {
		// TODO Auto-generated method stub
		return dao;
	}
	public List<CompletionClassification> queryByfilter(
			CompletionClassificationFilter filter) {
		return dao.queryByfilter(filter);
	}
	public List<CompletionClassification> queryByValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryByValue(filter);
	}
	public List<CompletionClassification> queryByXZValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryByXZValue(filter);
	}

	public String queryNewDate(
			IndicatorBreakdownFilter filter) {
		return dao.queryNewDate(filter);
	}
	public String queryNewDateGuTou(
			IndicatorBreakdownFilter filter) {
		return dao.queryNewDateGuTou(filter);
	}

	public List<CompletionClassification> queryByHYValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryByHYValue(filter);
	}
	public CompletionClassification queryByHYValue1OrderBycompletionPeriod(
			IndicatorBreakdownFilter filter) {
		return dao.queryByHYValue1OrderBycompletionPeriod(filter);
	}
	public List<CompletionClassification> queryByHYValue1(
			IndicatorBreakdownFilter filter) {
		return dao.queryByHYValue1(filter);
	}
	public List<CompletionClassification> queryByDWValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryByDWValue(filter);
	}
	public List<CompletionClassification> queryByDWYearValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryByDWYearValue(filter);
	}
	public List<CompletionClassification> queryByHYValueSec(
			IndicatorBreakdownFilter filter) {
		return dao.queryByHYValueSec(filter);
	}
	public List<CompletionClassification> queryMonthValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryMonthValue(filter);
	}
	public List<CompletionClassification> queryCountyPreemptive(
			CompletionClassificationFilter filter) {
		return dao.queryCountyPreemptive(filter);
	}
	public List<CompletionClassification> queryByThiValue(
			IndicatorBreakdownFilter filter) {
		return dao.queryByThiValue(filter);
	}
	public List<CompletionClassification> queryPreemptive(
			CompletionClassificationFilter filter) {
		return dao.queryPreemptive(filter);
	}
	
	public List<Map<String, Object>> querySupportingRegionalProductRank(){
		List<Map<String, Object>> lists=new ArrayList<Map<String, Object>>();
		CompletionClassificationFilter filter=new CompletionClassificationFilter();
		filter.setIndustryId("A01");
		filter.setCategory("扶贫");
		filter.setYear("2016");
		List<CompletionClassification> list=dao.queryCountyPreemptive(filter);
		if(list.size()>0){
			int s=1;
		for(CompletionClassification cc:list){
			Map<String, Object> map = new HashMap<>();
			map.put("Time",df.format(new Date()));
			map.put("Ranking",s);
			if(ObjectUtils.isNotBlank(cc.getActualCompletionValue())){
			map.put("ProductValue", cc.getActualCompletionValue());
			}else{
				map.put("ProductValue","0");
			}
			map.put("AreaName", cc.getArea());
			lists.add(map);
			s++;
		}
		}
		return lists;
		
	}

}
